﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Xml;

namespace DZRemoteController
{
	public class RulesConfigSection : ConfigurationSection
	{
		[ConfigurationProperty("rules")]
		public RulesCollection Rules
		{
			get { return ((RulesCollection)(base["rules"])); }
		}
	}

	[ConfigurationCollection(typeof(RuleElement))]
	public class RulesCollection : ConfigurationElementCollection
	{
		protected override ConfigurationElement CreateNewElement()
		{

			return new RuleElement();

		}



		protected override object GetElementKey(ConfigurationElement element)
		{

			return ((RuleElement)(element)).RuleType;

		}



		public RuleElement this[int idx]
		{

			get
			{

				return (RuleElement)BaseGet(idx);

			}

		}
	}

	
	public class RuleElement : ConfigurationElement
	{
		[ConfigurationProperty("ruleType", DefaultValue = "", IsKey = false, IsRequired = true)]
		public string RuleType
		{
			get
			{
				return ((string)(base["ruleType"]));
			}
			set
			{
				base["ruleType"] = value;
			}
		}

		[ConfigurationProperty("entry", DefaultValue = "", IsKey = false, IsRequired = true)]
		public string Entry
		{
			get
			{
				return ((string)(base["entry"]));
			}

			set
			{
				base["entry"] = value;
			}
		}

		[ConfigurationProperty("fileName", DefaultValue = "", IsKey = false, IsRequired = true)]
		public string FileName
		{
			get
			{
				return ((string)(base["fileName"]));
			}

			set
			{
				base["fileName"] = value;
			}
		}

		[ConfigurationProperty("isSingle", DefaultValue = false, IsKey = false, IsRequired = false)]
		public bool IsSingle
		{
			get
			{
				return (bool)(base["isSingle"]);
			}

			set
			{
				base["isSingle"] = value;
			}
		}
	}

	public interface IRule
	{
		void Init(RuleElement rule);
		string Entry{ get; set;}
		bool Validate(string document);
		void Perform();
		bool IsActive { get; set; }
	}
	public class CodeRecievedEventArgs : EventArgs
	{
		public string Code { get; set; }

		public CodeRecievedEventArgs(string code)
		{
			Code = code;
		}
	}

	public interface IInputable
	{
		void Start();
		event EventHandler<CodeRecievedEventArgs> CodeRecieved;
		event EventHandler RefreshRecieved;
		void StartResponse();
		void EndResponse();
	}


	enum ActionType
	{
		
	}

}
